﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting.Contexts;
using System.Runtime.Remoting.Activation;
using System.Runtime.Remoting.Messaging;

namespace StockMatch.Service.AOPBasics
{
    public abstract class AOPProperty : IContextProperty, IContributeServerContextSink
    {
        public AOPProperty() { }
        public void Freeze(Context newContext)
        {
            
        }

        public bool IsNewContextOK(Context newCtx)
        {
            return true;
        }

        public string Name
        {
            get { return GetName(); }
        }

        protected virtual string GetName()
        {
            return "AOP";
        }

        protected abstract IMessageSink CreateAOPAspect(IMessageSink nextSink);

        public IMessageSink GetServerContextSink(IMessageSink nextSink)
        {
            AOPAspect aopAspect = CreateAOPAspect(nextSink) as AOPAspect;
            aopAspect.AOPPropertyName = Name;
            return (IMessageSink)aopAspect;
        }
    }
}
